The JPEG scheme, which has been standardized by the ISO (International Standardization Organization), has been in widespread use as an encoding scheme for storing and displaying still images on a recording medium such as a CD-ROM or hard disk. Further, the MPEG scheme standardized by the ISO has been in wide use as an encoding scheme of moving images for similarly storing and displaying moving images on a recording medium and either broadcasting these images via a communication path or transmitting them bi-directionally.
When image encoding is performed in both the JPEG and MPEG schemes, an encoded data stream is generated. The data stream comprises a header and an image data portion. The header includes information that is necessary for decoding an image, such as size of the image, number of color components constituting the image and sampling coefficient values for every color component. The image data portion is image data that is the result of entropy encoding by variable-length encoding.
With block interleaving that repeatedly encodes color components every block of 8×8 pixels in such an encoded data stream, the term “minimum coded unit” (MCU) is used to refer to the smallest unit in a case where blocks of all color components have been encoded based upon sampling coefficients. For example, in the case of an image in which color components are luminance Y and color differences Cb and Cr and the sampling coefficients are 2:1:1, respectively, one MCU is composed of four blocks of (Y, Y, Cb, Cr).
A re-synchronization identifier referred to as a “restart marker” can be inserted into an encoded data stream at any intervals using the MCU as the unit. If an encoded data stream that contains an error for some reason is decoded, the effects of the error can be kept within the limits of the re-start marker interval. It is stipulated that the restart markers be present at the byte boundaries in the encoded data stream. If an encoded data stream immediately prior to insertion of the restart marker does not end at the byte boundary, the restart marker is inserted following insertion of a plurality of “1”s of one to seven bits referred to as “parity bits”.
If an encoded data stream that contains a code error for some reason is decoded, much of the code error is detected as a result of either of the following phenomena:
(1) detection of a variable-length code that does not exist in a conversion table used at the time of encoding; or
(2) detection of 64 or more variable-length codes in one block.
If restart markers have been inserted into an encoded data stream, it is possible to search for the encoded data stream starting from the location at which the error code was detected and decoding can be resumed from the location at which the next restart marker appears. By inserting compensation data with regard to undecodable coded data between a location at which code error has been detected and a location at which a restart marker appears, it is possible to obtain a reconstructed image of identical size in which the numbers of horizontal and vertical pixels agree with those of the original image.
Even if a restart marker does not appear in an encoded data stream from the location of code error detection onward, inserting compensation data so as to satisfy the numbers of horizontal and vertical pixels of the original image will make it possible to obtain a reconstructed image in which at least the portion of the image that prevailed prior to detection of the error can be displayed.
However, in the conventional image processing apparatus, error compensation processing for finding a restart marker from an encoded data stream from the location of code error detection onward and inserting compensation data is not executed in the decoding of an encoded data stream that does not contain the usual code error. From the standpoint of cost, therefore, such an image processing apparatus generally is implemented as software on a microprocessor rather than as hardware. From the standpoint of processing speed, however, software implementation requires a longer processing time than hardware implementation.
Once code error has been detected in an encoded data stream composed of contiguous variable-length codes, it is necessary to examine the encoded data stream sequentially from the location of error code detection onward in order to ascertain to what degree error code is contained in the overall encoded data stream. Accordingly, in a case where much code error is dispersed in an image of large size, the examination cannot be made unless the four processes of code-error detection, restart-marker search, compensation and resumption of decoding are repeated. Among these four processes, the processing for restart-marker search and compensation generally implemented by software occupies the major part of the processing time required for overall decoding. As a consequence, a very long processing time is required for decoding. This detracts markedly from user convenience.
Further, the above-described problem becomes particularly pronounced in decoding processing of a moving image in which the number of images to be processed per unit time is stipulated.